const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
const VuePlugin = require("./vue-loader/plugin.js");

/**
 * @type {webpack.Configuration}
 */
module.exports = {
  mode: "production",
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: path.resolve(__dirname, "./vue-loader/loader.js"),
      },
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"],
      },
    ],
  },
  plugins: [
    new VuePlugin(),
    new HtmlWebpackPlugin({
      template: "index.html",
    }),
  ],
  optimization: {
    splitChunks: {
      chunks: "all",
      cacheGroups: {
        vue: {
          name: "vue",
          test: /node_modules\/[@]vue/,
          priority: 20,
        },
      },
    },
  },
};
